package cn.javabb.common.enums;

/**
 * @desc:
 * @author: javabb (javabob(a)163.com)
 * @create: 2019/11/04 15:46
 */
public enum ResponseEnum {
    /**
     * 通用状态
     */
    SUCCESS(200, "操作成功！"),
    ERROR(500, "服务器未知错误！"),
    /**
     * 账号问题
     */
    UNAUTHORIZED(401, "尚未登录！"),
    FORBIDDEN(403, "您没有操作权限！"),
    NOT_FOUND(404, "资源不存在！"),
    LOGIN_ERROR(500, "账号或密码错误！"),
    USER_EXIST(500, "已存在的用户！"),
    INVALID_AUTHCODE(500, "手机验证码无效！"),
    INVALID_TOKEN(500, "无效的TOKEN，您没有操作权限！"),
    INVALID_ACCESS(500, "无效的请求，该请求已过期！"),
    DELETE_ERROR(500, "删除失败！"),

    EXIST_NOPAY_ORDER(3001, "存在未支付的订单"),

    PARAM_ERROR(400, "参数错误"),
    ;

    private Integer code;
    private String message;

    ResponseEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ResponseEnum getResponseStatus(String message) {
        for (ResponseEnum re : ResponseEnum.values()) {
            if (re.getMessage() == message) {
                return re;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
